/*
 * Copyright (c) 2017 Kotlin Algorithm Club
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package io.uuddlrlrba.ktalgs.geometry

import org.junit.Assert
import org.junit.Test

class VoronoiTest {
    @Test(expected= IllegalArgumentException::class)
    fun testException() {
        Voronoi(emptyList(), Point.EUCLIDEAN_DISTANCE_FUNC)
    }

    @Test
    fun test1() {
        val v = Voronoi(listOf(Point(0, 0)), Point.EUCLIDEAN_DISTANCE_FUNC)
        Assert.assertEquals(1, v.count)
        Assert.assertEquals(Point(0, 0), v.region(Point(-100, -100)))
        Assert.assertEquals(Point(0, 0), v.region(Point(-100, 100)))
        Assert.assertEquals(Point(0, 0), v.region(Point(100, 100)))
        Assert.assertEquals(Point(0, 0), v.region(Point(100, -100)))
    }

    @Test
    fun test2() {
        val v = Voronoi(
                listOf(
                        Point(41, 98),
                        Point(59, 97),
                        Point(87, 26),
                        Point(3, 33),
                        Point(18, 46),
                        Point(57, 81),
                        Point(65, 29),
                        Point(20, 32),
                        Point(73, 96),
                        Point(81, 90)
                ), Point.EUCLIDEAN_DISTANCE_FUNC
        )
        Assert.assertEquals(10, v.count)
        Assert.assertEquals(Point(3, 33), v.region(Point(0, 0)))
        Assert.assertEquals(Point(3, 33), v.region(Point(0, 10)))
        Assert.assertEquals(Point(3, 33), v.region(Point(0, 20)))
        Assert.assertEquals(Point(3, 33), v.region(Point(0, 30)))
        Assert.assertEquals(Point(3, 33), v.region(Point(0, 40)))
        Assert.assertEquals(Point(3, 33), v.region(Point(0, 50)))
        Assert.assertEquals(Point(18, 46), v.region(Point(0, 60)))
        Assert.assertEquals(Point(18, 46), v.region(Point(0, 70)))
        Assert.assertEquals(Point(18, 46), v.region(Point(0, 80)))
        Assert.assertEquals(Point(41, 98), v.region(Point(0, 90)))
        Assert.assertEquals(Point(20, 32), v.region(Point(10, 0)))
        Assert.assertEquals(Point(3, 33), v.region(Point(10, 10)))
        Assert.assertEquals(Point(3, 33), v.region(Point(10, 20)))
        Assert.assertEquals(Point(3, 33), v.region(Point(10, 30)))
        Assert.assertEquals(Point(3, 33), v.region(Point(10, 40)))
        Assert.assertEquals(Point(18, 46), v.region(Point(10, 50)))
        Assert.assertEquals(Point(18, 46), v.region(Point(10, 60)))
        Assert.assertEquals(Point(18, 46), v.region(Point(10, 70)))
        Assert.assertEquals(Point(18, 46), v.region(Point(10, 80)))
        Assert.assertEquals(Point(41, 98), v.region(Point(10, 90)))
        Assert.assertEquals(Point(20, 32), v.region(Point(20, 0)))
        Assert.assertEquals(Point(20, 32), v.region(Point(20, 10)))
        Assert.assertEquals(Point(20, 32), v.region(Point(20, 20)))
        Assert.assertEquals(Point(20, 32), v.region(Point(20, 30)))
        Assert.assertEquals(Point(18, 46), v.region(Point(20, 40)))
        Assert.assertEquals(Point(18, 46), v.region(Point(20, 50)))
        Assert.assertEquals(Point(18, 46), v.region(Point(20, 60)))
        Assert.assertEquals(Point(18, 46), v.region(Point(20, 70)))
        Assert.assertEquals(Point(41, 98), v.region(Point(20, 80)))
        Assert.assertEquals(Point(41, 98), v.region(Point(20, 90)))
        Assert.assertEquals(Point(20, 32), v.region(Point(30, 0)))
        Assert.assertEquals(Point(20, 32), v.region(Point(30, 10)))
        Assert.assertEquals(Point(20, 32), v.region(Point(30, 20)))
        Assert.assertEquals(Point(20, 32), v.region(Point(30, 30)))
        Assert.assertEquals(Point(20, 32), v.region(Point(30, 40)))
        Assert.assertEquals(Point(18, 46), v.region(Point(30, 50)))
        Assert.assertEquals(Point(18, 46), v.region(Point(30, 60)))
        Assert.assertEquals(Point(18, 46), v.region(Point(30, 70)))
        Assert.assertEquals(Point(41, 98), v.region(Point(30, 80)))
        Assert.assertEquals(Point(41, 98), v.region(Point(30, 90)))
        Assert.assertEquals(Point(20, 32), v.region(Point(40, 0)))
        Assert.assertEquals(Point(20, 32), v.region(Point(40, 10)))
        Assert.assertEquals(Point(20, 32), v.region(Point(40, 20)))
        Assert.assertEquals(Point(20, 32), v.region(Point(40, 30)))
        Assert.assertEquals(Point(20, 32), v.region(Point(40, 40)))
        Assert.assertEquals(Point(18, 46), v.region(Point(40, 50)))
        Assert.assertEquals(Point(18, 46), v.region(Point(40, 60)))
        Assert.assertEquals(Point(57, 81), v.region(Point(40, 70)))
        Assert.assertEquals(Point(57, 81), v.region(Point(40, 80)))
        Assert.assertEquals(Point(41, 98), v.region(Point(40, 90)))
        Assert.assertEquals(Point(65, 29), v.region(Point(50, 0)))
        Assert.assertEquals(Point(65, 29), v.region(Point(50, 10)))
        Assert.assertEquals(Point(65, 29), v.region(Point(50, 20)))
        Assert.assertEquals(Point(65, 29), v.region(Point(50, 30)))
        Assert.assertEquals(Point(65, 29), v.region(Point(50, 40)))
        Assert.assertEquals(Point(65, 29), v.region(Point(50, 50)))
        Assert.assertEquals(Point(57, 81), v.region(Point(50, 60)))
        Assert.assertEquals(Point(57, 81), v.region(Point(50, 70)))
        Assert.assertEquals(Point(57, 81), v.region(Point(50, 80)))
        Assert.assertEquals(Point(59, 97), v.region(Point(50, 90)))
        Assert.assertEquals(Point(65, 29), v.region(Point(60, 0)))
        Assert.assertEquals(Point(65, 29), v.region(Point(60, 10)))
        Assert.assertEquals(Point(65, 29), v.region(Point(60, 20)))
        Assert.assertEquals(Point(65, 29), v.region(Point(60, 30)))
        Assert.assertEquals(Point(65, 29), v.region(Point(60, 40)))
        Assert.assertEquals(Point(65, 29), v.region(Point(60, 50)))
        Assert.assertEquals(Point(57, 81), v.region(Point(60, 60)))
        Assert.assertEquals(Point(57, 81), v.region(Point(60, 70)))
        Assert.assertEquals(Point(57, 81), v.region(Point(60, 80)))
        Assert.assertEquals(Point(59, 97), v.region(Point(60, 90)))
        Assert.assertEquals(Point(65, 29), v.region(Point(70, 0)))
        Assert.assertEquals(Point(65, 29), v.region(Point(70, 10)))
        Assert.assertEquals(Point(65, 29), v.region(Point(70, 20)))
        Assert.assertEquals(Point(65, 29), v.region(Point(70, 30)))
        Assert.assertEquals(Point(65, 29), v.region(Point(70, 40)))
        Assert.assertEquals(Point(65, 29), v.region(Point(70, 50)))
        Assert.assertEquals(Point(57, 81), v.region(Point(70, 60)))
        Assert.assertEquals(Point(57, 81), v.region(Point(70, 70)))
        Assert.assertEquals(Point(57, 81), v.region(Point(70, 80)))
        Assert.assertEquals(Point(73, 96), v.region(Point(70, 90)))
        Assert.assertEquals(Point(87, 26), v.region(Point(80, 0)))
        Assert.assertEquals(Point(87, 26), v.region(Point(80, 10)))
        Assert.assertEquals(Point(87, 26), v.region(Point(80, 20)))
        Assert.assertEquals(Point(87, 26), v.region(Point(80, 30)))
        Assert.assertEquals(Point(87, 26), v.region(Point(80, 40)))
        Assert.assertEquals(Point(87, 26), v.region(Point(80, 50)))
        Assert.assertEquals(Point(81, 90), v.region(Point(80, 60)))
        Assert.assertEquals(Point(81, 90), v.region(Point(80, 70)))
        Assert.assertEquals(Point(81, 90), v.region(Point(80, 80)))
        Assert.assertEquals(Point(81, 90), v.region(Point(80, 90)))
        Assert.assertEquals(Point(87, 26), v.region(Point(90, 0)))
        Assert.assertEquals(Point(87, 26), v.region(Point(90, 10)))
        Assert.assertEquals(Point(87, 26), v.region(Point(90, 20)))
        Assert.assertEquals(Point(87, 26), v.region(Point(90, 30)))
        Assert.assertEquals(Point(87, 26), v.region(Point(90, 40)))
        Assert.assertEquals(Point(87, 26), v.region(Point(90, 50)))
        Assert.assertEquals(Point(81, 90), v.region(Point(90, 60)))
        Assert.assertEquals(Point(81, 90), v.region(Point(90, 70)))
        Assert.assertEquals(Point(81, 90), v.region(Point(90, 80)))
        Assert.assertEquals(Point(81, 90), v.region(Point(90, 90)))
    }

    @Test
    fun test3() {
        val v = Voronoi(
                listOf(
                        Point(16, 9),
                        Point(17, 2),
                        Point(5, 19),
                        Point(3, 24),
                        Point(17, 12),
                        Point(15, 10),
                        Point(12, 1),
                        Point(21, 4),
                        Point(11, 21),
                        Point(1, 20),
                        Point(11, 13),
                        Point(13, 4),
                        Point(15, 8),
                        Point(22, 20),
                        Point(21, 20),
                        Point(24, 0),
                        Point(2, 12),
                        Point(3, 22),
                        Point(19, 5),
                        Point(19, 7),
                        Point(19, 8),
                        Point(0, 18),
                        Point(17, 20),
                        Point(17, 0),
                        Point(13, 0)
                ), Point.EUCLIDEAN_DISTANCE_FUNC
        )
        Assert.assertEquals(25, v.count)
        Assert.assertEquals(Point(12, 1), v.region(Point(0, 0)))
        Assert.assertEquals(Point(2, 12), v.region(Point(0, 5)))
        Assert.assertEquals(Point(2, 12), v.region(Point(0, 10)))
        Assert.assertEquals(Point(0, 18), v.region(Point(0, 15)))
        Assert.assertEquals(Point(1, 20), v.region(Point(0, 20)))
        Assert.assertEquals(Point(12, 1), v.region(Point(5, 0)))
        Assert.assertEquals(Point(2, 12), v.region(Point(5, 5)))
        Assert.assertEquals(Point(2, 12), v.region(Point(5, 10)))
        Assert.assertEquals(Point(5, 19), v.region(Point(5, 15)))
        Assert.assertEquals(Point(5, 19), v.region(Point(5, 20)))
        Assert.assertEquals(Point(12, 1), v.region(Point(10, 0)))
        Assert.assertEquals(Point(13, 4), v.region(Point(10, 5)))
        Assert.assertEquals(Point(11, 13), v.region(Point(10, 10)))
        Assert.assertEquals(Point(11, 13), v.region(Point(10, 15)))
        Assert.assertEquals(Point(11, 21), v.region(Point(10, 20)))
        Assert.assertEquals(Point(17, 0), v.region(Point(15, 0)))
        Assert.assertEquals(Point(13, 4), v.region(Point(15, 5)))
        Assert.assertEquals(Point(15, 10), v.region(Point(15, 10)))
        Assert.assertEquals(Point(17, 12), v.region(Point(15, 15)))
        Assert.assertEquals(Point(17, 20), v.region(Point(15, 20)))
        Assert.assertEquals(Point(17, 0), v.region(Point(20, 0)))
        Assert.assertEquals(Point(19, 5), v.region(Point(20, 5)))
        Assert.assertEquals(Point(19, 8), v.region(Point(20, 10)))
        Assert.assertEquals(Point(17, 12), v.region(Point(20, 15)))
        Assert.assertEquals(Point(21, 20), v.region(Point(20, 20)))
    }

    @Test
    fun test4() {
        val v = Voronoi(
                listOf(
                        Point(7, 2),
                        Point(6, 6),
                        Point(8, 9)
                ), Point.EUCLIDEAN_DISTANCE_FUNC
        )
        Assert.assertEquals(Point(7, 2), v.region(Point(0, 0)))
        Assert.assertEquals(Point(7, 2), v.region(Point(0, 2)))
        Assert.assertEquals(Point(6, 6), v.region(Point(0, 4)))
        Assert.assertEquals(Point(6, 6), v.region(Point(0, 6)))
        Assert.assertEquals(Point(6, 6), v.region(Point(0, 8)))
        Assert.assertEquals(Point(7, 2), v.region(Point(2, 0)))
        Assert.assertEquals(Point(7, 2), v.region(Point(2, 2)))
        Assert.assertEquals(Point(6, 6), v.region(Point(2, 4)))
        Assert.assertEquals(Point(6, 6), v.region(Point(2, 6)))
        Assert.assertEquals(Point(6, 6), v.region(Point(2, 8)))
        Assert.assertEquals(Point(7, 2), v.region(Point(4, 0)))
        Assert.assertEquals(Point(7, 2), v.region(Point(4, 2)))
        Assert.assertEquals(Point(6, 6), v.region(Point(4, 4)))
        Assert.assertEquals(Point(6, 6), v.region(Point(4, 6)))
        Assert.assertEquals(Point(6, 6), v.region(Point(4, 8)))
        Assert.assertEquals(Point(7, 2), v.region(Point(6, 0)))
        Assert.assertEquals(Point(7, 2), v.region(Point(6, 2)))
        Assert.assertEquals(Point(6, 6), v.region(Point(6, 4)))
        Assert.assertEquals(Point(6, 6), v.region(Point(6, 6)))
        Assert.assertEquals(Point(6, 6), v.region(Point(6, 8)))
        Assert.assertEquals(Point(7, 2), v.region(Point(8, 0)))
        Assert.assertEquals(Point(7, 2), v.region(Point(8, 2)))
        Assert.assertEquals(Point(7, 2), v.region(Point(8, 4)))
        Assert.assertEquals(Point(6, 6), v.region(Point(8, 6)))
        Assert.assertEquals(Point(8, 9), v.region(Point(8, 8)))
    }

    @Test
    fun test5() {
        val v = Voronoi(
                listOf(
                        Point(44, 27),
                        Point(2, 35),
                        Point(24, 10),
                        Point(45, 25),
                        Point(29, 39),
                        Point(32, 9),
                        Point(15, 16),
                        Point(17, 40),
                        Point(7, 6),
                        Point(6, 5),
                        Point(39, 15),
                        Point(20, 1),
                        Point(29, 20),
                        Point(6, 36),
                        Point(40, 28),
                        Point(41, 4),
                        Point(41, 34),
                        Point(36, 11),
                        Point(8, 19),
                        Point(37, 34),
                        Point(29, 35),
                        Point(44, 42),
                        Point(20, 45),
                        Point(10, 43),
                        Point(37, 39),
                        Point(42, 9),
                        Point(11, 32),
                        Point(16, 38),
                        Point(32, 41),
                        Point(23, 12),
                        Point(15, 40),
                        Point(5, 42),
                        Point(7, 31),
                        Point(2, 23),
                        Point(42, 36),
                        Point(10, 12),
                        Point(47, 27),
                        Point(27, 20),
                        Point(26, 1),
                        Point(23, 25),
                        Point(47, 7),
                        Point(4, 36),
                        Point(49, 7),
                        Point(40, 26),
                        Point(13, 21),
                        Point(11, 6),
                        Point(34, 21),
                        Point(1, 40),
                        Point(43, 30),
                        Point(12, 48)
                ), Point.EUCLIDEAN_DISTANCE_FUNC
        )
        Assert.assertEquals(50, v.count)
        Assert.assertEquals(Point(6, 5), v.region(Point(0, 0)))
        Assert.assertEquals(Point(6, 5), v.region(Point(0, 2)))
        Assert.assertEquals(Point(6, 5), v.region(Point(0, 4)))
        Assert.assertEquals(Point(6, 5), v.region(Point(0, 6)))
        Assert.assertEquals(Point(6, 5), v.region(Point(0, 8)))
        Assert.assertEquals(Point(6, 5), v.region(Point(0, 10)))
        Assert.assertEquals(Point(7, 6), v.region(Point(0, 12)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 14)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 16)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 18)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 20)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 22)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 24)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 26)))
        Assert.assertEquals(Point(2, 23), v.region(Point(0, 28)))
        Assert.assertEquals(Point(2, 35), v.region(Point(0, 30)))
        Assert.assertEquals(Point(2, 35), v.region(Point(0, 32)))
        Assert.assertEquals(Point(2, 35), v.region(Point(0, 34)))
        Assert.assertEquals(Point(2, 35), v.region(Point(0, 36)))
        Assert.assertEquals(Point(1, 40), v.region(Point(0, 38)))
        Assert.assertEquals(Point(1, 40), v.region(Point(0, 40)))
        Assert.assertEquals(Point(1, 40), v.region(Point(0, 42)))
        Assert.assertEquals(Point(1, 40), v.region(Point(0, 44)))
        Assert.assertEquals(Point(1, 40), v.region(Point(0, 46)))
        Assert.assertEquals(Point(5, 42), v.region(Point(0, 48)))
        Assert.assertEquals(Point(6, 5), v.region(Point(2, 0)))
        Assert.assertEquals(Point(6, 5), v.region(Point(2, 2)))
        Assert.assertEquals(Point(6, 5), v.region(Point(2, 4)))
        Assert.assertEquals(Point(6, 5), v.region(Point(2, 6)))
        Assert.assertEquals(Point(6, 5), v.region(Point(2, 8)))
        Assert.assertEquals(Point(7, 6), v.region(Point(2, 10)))
        Assert.assertEquals(Point(7, 6), v.region(Point(2, 12)))
        Assert.assertEquals(Point(8, 19), v.region(Point(2, 14)))
        Assert.assertEquals(Point(8, 19), v.region(Point(2, 16)))
        Assert.assertEquals(Point(2, 23), v.region(Point(2, 18)))
        Assert.assertEquals(Point(2, 23), v.region(Point(2, 20)))
        Assert.assertEquals(Point(2, 23), v.region(Point(2, 22)))
        Assert.assertEquals(Point(2, 23), v.region(Point(2, 24)))
        Assert.assertEquals(Point(2, 23), v.region(Point(2, 26)))
        Assert.assertEquals(Point(2, 23), v.region(Point(2, 28)))
        Assert.assertEquals(Point(2, 35), v.region(Point(2, 30)))
        Assert.assertEquals(Point(2, 35), v.region(Point(2, 32)))
        Assert.assertEquals(Point(2, 35), v.region(Point(2, 34)))
        Assert.assertEquals(Point(2, 35), v.region(Point(2, 36)))
        Assert.assertEquals(Point(1, 40), v.region(Point(2, 38)))
        Assert.assertEquals(Point(1, 40), v.region(Point(2, 40)))
        Assert.assertEquals(Point(1, 40), v.region(Point(2, 42)))
        Assert.assertEquals(Point(5, 42), v.region(Point(2, 44)))
        Assert.assertEquals(Point(5, 42), v.region(Point(2, 46)))
        Assert.assertEquals(Point(5, 42), v.region(Point(2, 48)))
        Assert.assertEquals(Point(6, 5), v.region(Point(4, 0)))
        Assert.assertEquals(Point(6, 5), v.region(Point(4, 2)))
        Assert.assertEquals(Point(6, 5), v.region(Point(4, 4)))
        Assert.assertEquals(Point(6, 5), v.region(Point(4, 6)))
        Assert.assertEquals(Point(7, 6), v.region(Point(4, 8)))
        Assert.assertEquals(Point(7, 6), v.region(Point(4, 10)))
        Assert.assertEquals(Point(10, 12), v.region(Point(4, 12)))
        Assert.assertEquals(Point(10, 12), v.region(Point(4, 14)))
        Assert.assertEquals(Point(8, 19), v.region(Point(4, 16)))
        Assert.assertEquals(Point(8, 19), v.region(Point(4, 18)))
        Assert.assertEquals(Point(2, 23), v.region(Point(4, 20)))
        Assert.assertEquals(Point(2, 23), v.region(Point(4, 22)))
        Assert.assertEquals(Point(2, 23), v.region(Point(4, 24)))
        Assert.assertEquals(Point(2, 23), v.region(Point(4, 26)))
        Assert.assertEquals(Point(7, 31), v.region(Point(4, 28)))
        Assert.assertEquals(Point(7, 31), v.region(Point(4, 30)))
        Assert.assertEquals(Point(7, 31), v.region(Point(4, 32)))
        Assert.assertEquals(Point(4, 36), v.region(Point(4, 34)))
        Assert.assertEquals(Point(4, 36), v.region(Point(4, 36)))
        Assert.assertEquals(Point(4, 36), v.region(Point(4, 38)))
        Assert.assertEquals(Point(5, 42), v.region(Point(4, 40)))
        Assert.assertEquals(Point(5, 42), v.region(Point(4, 42)))
        Assert.assertEquals(Point(5, 42), v.region(Point(4, 44)))
        Assert.assertEquals(Point(5, 42), v.region(Point(4, 46)))
        Assert.assertEquals(Point(5, 42), v.region(Point(4, 48)))
        Assert.assertEquals(Point(6, 5), v.region(Point(6, 0)))
        Assert.assertEquals(Point(6, 5), v.region(Point(6, 2)))
        Assert.assertEquals(Point(6, 5), v.region(Point(6, 4)))
        Assert.assertEquals(Point(7, 6), v.region(Point(6, 6)))
        Assert.assertEquals(Point(7, 6), v.region(Point(6, 8)))
        Assert.assertEquals(Point(7, 6), v.region(Point(6, 10)))
        Assert.assertEquals(Point(10, 12), v.region(Point(6, 12)))
        Assert.assertEquals(Point(10, 12), v.region(Point(6, 14)))
        Assert.assertEquals(Point(8, 19), v.region(Point(6, 16)))
        Assert.assertEquals(Point(8, 19), v.region(Point(6, 18)))
        Assert.assertEquals(Point(8, 19), v.region(Point(6, 20)))
        Assert.assertEquals(Point(8, 19), v.region(Point(6, 22)))
        Assert.assertEquals(Point(2, 23), v.region(Point(6, 24)))
        Assert.assertEquals(Point(2, 23), v.region(Point(6, 26)))
        Assert.assertEquals(Point(7, 31), v.region(Point(6, 28)))
        Assert.assertEquals(Point(7, 31), v.region(Point(6, 30)))
        Assert.assertEquals(Point(7, 31), v.region(Point(6, 32)))
        Assert.assertEquals(Point(6, 36), v.region(Point(6, 34)))
        Assert.assertEquals(Point(6, 36), v.region(Point(6, 36)))
        Assert.assertEquals(Point(6, 36), v.region(Point(6, 38)))
        Assert.assertEquals(Point(5, 42), v.region(Point(6, 40)))
        Assert.assertEquals(Point(5, 42), v.region(Point(6, 42)))
        Assert.assertEquals(Point(5, 42), v.region(Point(6, 44)))
        Assert.assertEquals(Point(5, 42), v.region(Point(6, 46)))
        Assert.assertEquals(Point(12, 48), v.region(Point(6, 48)))
        Assert.assertEquals(Point(6, 5), v.region(Point(8, 0)))
        Assert.assertEquals(Point(6, 5), v.region(Point(8, 2)))
        Assert.assertEquals(Point(7, 6), v.region(Point(8, 4)))
        Assert.assertEquals(Point(7, 6), v.region(Point(8, 6)))
        Assert.assertEquals(Point(7, 6), v.region(Point(8, 8)))
        Assert.assertEquals(Point(10, 12), v.region(Point(8, 10)))
        Assert.assertEquals(Point(10, 12), v.region(Point(8, 12)))
        Assert.assertEquals(Point(10, 12), v.region(Point(8, 14)))
        Assert.assertEquals(Point(8, 19), v.region(Point(8, 16)))
        Assert.assertEquals(Point(8, 19), v.region(Point(8, 18)))
        Assert.assertEquals(Point(8, 19), v.region(Point(8, 20)))
        Assert.assertEquals(Point(8, 19), v.region(Point(8, 22)))
        Assert.assertEquals(Point(8, 19), v.region(Point(8, 24)))
        Assert.assertEquals(Point(7, 31), v.region(Point(8, 26)))
        Assert.assertEquals(Point(7, 31), v.region(Point(8, 28)))
        Assert.assertEquals(Point(7, 31), v.region(Point(8, 30)))
        Assert.assertEquals(Point(7, 31), v.region(Point(8, 32)))
        Assert.assertEquals(Point(6, 36), v.region(Point(8, 34)))
        Assert.assertEquals(Point(6, 36), v.region(Point(8, 36)))
        Assert.assertEquals(Point(6, 36), v.region(Point(8, 38)))
        Assert.assertEquals(Point(10, 43), v.region(Point(8, 40)))
        Assert.assertEquals(Point(10, 43), v.region(Point(8, 42)))
        Assert.assertEquals(Point(10, 43), v.region(Point(8, 44)))
        Assert.assertEquals(Point(10, 43), v.region(Point(8, 46)))
        Assert.assertEquals(Point(12, 48), v.region(Point(8, 48)))
        Assert.assertEquals(Point(11, 6), v.region(Point(10, 0)))
        Assert.assertEquals(Point(11, 6), v.region(Point(10, 2)))
        Assert.assertEquals(Point(11, 6), v.region(Point(10, 4)))
        Assert.assertEquals(Point(11, 6), v.region(Point(10, 6)))
        Assert.assertEquals(Point(11, 6), v.region(Point(10, 8)))
        Assert.assertEquals(Point(10, 12), v.region(Point(10, 10)))
        Assert.assertEquals(Point(10, 12), v.region(Point(10, 12)))
        Assert.assertEquals(Point(10, 12), v.region(Point(10, 14)))
        Assert.assertEquals(Point(8, 19), v.region(Point(10, 16)))
        Assert.assertEquals(Point(8, 19), v.region(Point(10, 18)))
        Assert.assertEquals(Point(8, 19), v.region(Point(10, 20)))
        Assert.assertEquals(Point(13, 21), v.region(Point(10, 22)))
        Assert.assertEquals(Point(13, 21), v.region(Point(10, 24)))
        Assert.assertEquals(Point(7, 31), v.region(Point(10, 26)))
        Assert.assertEquals(Point(11, 32), v.region(Point(10, 28)))
        Assert.assertEquals(Point(11, 32), v.region(Point(10, 30)))
        Assert.assertEquals(Point(11, 32), v.region(Point(10, 32)))
        Assert.assertEquals(Point(11, 32), v.region(Point(10, 34)))
        Assert.assertEquals(Point(6, 36), v.region(Point(10, 36)))
        Assert.assertEquals(Point(6, 36), v.region(Point(10, 38)))
        Assert.assertEquals(Point(10, 43), v.region(Point(10, 40)))
        Assert.assertEquals(Point(10, 43), v.region(Point(10, 42)))
        Assert.assertEquals(Point(10, 43), v.region(Point(10, 44)))
        Assert.assertEquals(Point(12, 48), v.region(Point(10, 46)))
        Assert.assertEquals(Point(12, 48), v.region(Point(10, 48)))
        Assert.assertEquals(Point(11, 6), v.region(Point(12, 0)))
        Assert.assertEquals(Point(11, 6), v.region(Point(12, 2)))
        Assert.assertEquals(Point(11, 6), v.region(Point(12, 4)))
        Assert.assertEquals(Point(11, 6), v.region(Point(12, 6)))
        Assert.assertEquals(Point(11, 6), v.region(Point(12, 8)))
        Assert.assertEquals(Point(10, 12), v.region(Point(12, 10)))
        Assert.assertEquals(Point(10, 12), v.region(Point(12, 12)))
        Assert.assertEquals(Point(10, 12), v.region(Point(12, 14)))
        Assert.assertEquals(Point(15, 16), v.region(Point(12, 16)))
        Assert.assertEquals(Point(13, 21), v.region(Point(12, 18)))
        Assert.assertEquals(Point(13, 21), v.region(Point(12, 20)))
        Assert.assertEquals(Point(13, 21), v.region(Point(12, 22)))
        Assert.assertEquals(Point(13, 21), v.region(Point(12, 24)))
        Assert.assertEquals(Point(13, 21), v.region(Point(12, 26)))
        Assert.assertEquals(Point(11, 32), v.region(Point(12, 28)))
        Assert.assertEquals(Point(11, 32), v.region(Point(12, 30)))
        Assert.assertEquals(Point(11, 32), v.region(Point(12, 32)))
        Assert.assertEquals(Point(11, 32), v.region(Point(12, 34)))
        Assert.assertEquals(Point(11, 32), v.region(Point(12, 36)))
        Assert.assertEquals(Point(15, 40), v.region(Point(12, 38)))
        Assert.assertEquals(Point(15, 40), v.region(Point(12, 40)))
        Assert.assertEquals(Point(10, 43), v.region(Point(12, 42)))
        Assert.assertEquals(Point(10, 43), v.region(Point(12, 44)))
        Assert.assertEquals(Point(12, 48), v.region(Point(12, 46)))
        Assert.assertEquals(Point(12, 48), v.region(Point(12, 48)))
        Assert.assertEquals(Point(20, 1), v.region(Point(14, 0)))
        Assert.assertEquals(Point(11, 6), v.region(Point(14, 2)))
        Assert.assertEquals(Point(11, 6), v.region(Point(14, 4)))
        Assert.assertEquals(Point(11, 6), v.region(Point(14, 6)))
        Assert.assertEquals(Point(11, 6), v.region(Point(14, 8)))
        Assert.assertEquals(Point(10, 12), v.region(Point(14, 10)))
        Assert.assertEquals(Point(10, 12), v.region(Point(14, 12)))
        Assert.assertEquals(Point(15, 16), v.region(Point(14, 14)))
        Assert.assertEquals(Point(15, 16), v.region(Point(14, 16)))
        Assert.assertEquals(Point(15, 16), v.region(Point(14, 18)))
        Assert.assertEquals(Point(13, 21), v.region(Point(14, 20)))
        Assert.assertEquals(Point(13, 21), v.region(Point(14, 22)))
        Assert.assertEquals(Point(13, 21), v.region(Point(14, 24)))
        Assert.assertEquals(Point(13, 21), v.region(Point(14, 26)))
        Assert.assertEquals(Point(11, 32), v.region(Point(14, 28)))
        Assert.assertEquals(Point(11, 32), v.region(Point(14, 30)))
        Assert.assertEquals(Point(11, 32), v.region(Point(14, 32)))
        Assert.assertEquals(Point(11, 32), v.region(Point(14, 34)))
        Assert.assertEquals(Point(16, 38), v.region(Point(14, 36)))
        Assert.assertEquals(Point(16, 38), v.region(Point(14, 38)))
        Assert.assertEquals(Point(15, 40), v.region(Point(14, 40)))
        Assert.assertEquals(Point(15, 40), v.region(Point(14, 42)))
        Assert.assertEquals(Point(10, 43), v.region(Point(14, 44)))
        Assert.assertEquals(Point(12, 48), v.region(Point(14, 46)))
        Assert.assertEquals(Point(12, 48), v.region(Point(14, 48)))
        Assert.assertEquals(Point(20, 1), v.region(Point(16, 0)))
        Assert.assertEquals(Point(20, 1), v.region(Point(16, 2)))
        Assert.assertEquals(Point(20, 1), v.region(Point(16, 4)))
        Assert.assertEquals(Point(11, 6), v.region(Point(16, 6)))
        Assert.assertEquals(Point(11, 6), v.region(Point(16, 8)))
        Assert.assertEquals(Point(15, 16), v.region(Point(16, 10)))
        Assert.assertEquals(Point(15, 16), v.region(Point(16, 12)))
        Assert.assertEquals(Point(15, 16), v.region(Point(16, 14)))
        Assert.assertEquals(Point(15, 16), v.region(Point(16, 16)))
        Assert.assertEquals(Point(15, 16), v.region(Point(16, 18)))
        Assert.assertEquals(Point(13, 21), v.region(Point(16, 20)))
        Assert.assertEquals(Point(13, 21), v.region(Point(16, 22)))
        Assert.assertEquals(Point(13, 21), v.region(Point(16, 24)))
        Assert.assertEquals(Point(13, 21), v.region(Point(16, 26)))
        Assert.assertEquals(Point(11, 32), v.region(Point(16, 28)))
        Assert.assertEquals(Point(11, 32), v.region(Point(16, 30)))
        Assert.assertEquals(Point(11, 32), v.region(Point(16, 32)))
        Assert.assertEquals(Point(16, 38), v.region(Point(16, 34)))
        Assert.assertEquals(Point(16, 38), v.region(Point(16, 36)))
        Assert.assertEquals(Point(16, 38), v.region(Point(16, 38)))
        Assert.assertEquals(Point(17, 40), v.region(Point(16, 40)))
        Assert.assertEquals(Point(17, 40), v.region(Point(16, 42)))
        Assert.assertEquals(Point(17, 40), v.region(Point(16, 44)))
        Assert.assertEquals(Point(20, 45), v.region(Point(16, 46)))
        Assert.assertEquals(Point(12, 48), v.region(Point(16, 48)))
        Assert.assertEquals(Point(20, 1), v.region(Point(18, 0)))
        Assert.assertEquals(Point(20, 1), v.region(Point(18, 2)))
        Assert.assertEquals(Point(20, 1), v.region(Point(18, 4)))
        Assert.assertEquals(Point(20, 1), v.region(Point(18, 6)))
        Assert.assertEquals(Point(24, 10), v.region(Point(18, 8)))
        Assert.assertEquals(Point(23, 12), v.region(Point(18, 10)))
        Assert.assertEquals(Point(15, 16), v.region(Point(18, 12)))
        Assert.assertEquals(Point(15, 16), v.region(Point(18, 14)))
        Assert.assertEquals(Point(15, 16), v.region(Point(18, 16)))
        Assert.assertEquals(Point(15, 16), v.region(Point(18, 18)))
        Assert.assertEquals(Point(15, 16), v.region(Point(18, 20)))
        Assert.assertEquals(Point(13, 21), v.region(Point(18, 22)))
        Assert.assertEquals(Point(23, 25), v.region(Point(18, 24)))
        Assert.assertEquals(Point(23, 25), v.region(Point(18, 26)))
        Assert.assertEquals(Point(23, 25), v.region(Point(18, 28)))
        Assert.assertEquals(Point(23, 25), v.region(Point(18, 30)))
        Assert.assertEquals(Point(16, 38), v.region(Point(18, 32)))
        Assert.assertEquals(Point(16, 38), v.region(Point(18, 34)))
        Assert.assertEquals(Point(16, 38), v.region(Point(18, 36)))
        Assert.assertEquals(Point(16, 38), v.region(Point(18, 38)))
        Assert.assertEquals(Point(17, 40), v.region(Point(18, 40)))
        Assert.assertEquals(Point(17, 40), v.region(Point(18, 42)))
        Assert.assertEquals(Point(20, 45), v.region(Point(18, 44)))
        Assert.assertEquals(Point(20, 45), v.region(Point(18, 46)))
        Assert.assertEquals(Point(20, 45), v.region(Point(18, 48)))
        Assert.assertEquals(Point(20, 1), v.region(Point(20, 0)))
        Assert.assertEquals(Point(20, 1), v.region(Point(20, 2)))
        Assert.assertEquals(Point(20, 1), v.region(Point(20, 4)))
        Assert.assertEquals(Point(20, 1), v.region(Point(20, 6)))
        Assert.assertEquals(Point(24, 10), v.region(Point(20, 8)))
        Assert.assertEquals(Point(23, 12), v.region(Point(20, 10)))
        Assert.assertEquals(Point(23, 12), v.region(Point(20, 12)))
        Assert.assertEquals(Point(23, 12), v.region(Point(20, 14)))
        Assert.assertEquals(Point(15, 16), v.region(Point(20, 16)))
        Assert.assertEquals(Point(15, 16), v.region(Point(20, 18)))
        Assert.assertEquals(Point(23, 25), v.region(Point(20, 20)))
        Assert.assertEquals(Point(23, 25), v.region(Point(20, 22)))
        Assert.assertEquals(Point(23, 25), v.region(Point(20, 24)))
        Assert.assertEquals(Point(23, 25), v.region(Point(20, 26)))
        Assert.assertEquals(Point(23, 25), v.region(Point(20, 28)))
        Assert.assertEquals(Point(23, 25), v.region(Point(20, 30)))
        Assert.assertEquals(Point(16, 38), v.region(Point(20, 32)))
        Assert.assertEquals(Point(16, 38), v.region(Point(20, 34)))
        Assert.assertEquals(Point(16, 38), v.region(Point(20, 36)))
        Assert.assertEquals(Point(17, 40), v.region(Point(20, 38)))
        Assert.assertEquals(Point(17, 40), v.region(Point(20, 40)))
        Assert.assertEquals(Point(20, 45), v.region(Point(20, 42)))
        Assert.assertEquals(Point(20, 45), v.region(Point(20, 44)))
        Assert.assertEquals(Point(20, 45), v.region(Point(20, 46)))
        Assert.assertEquals(Point(20, 45), v.region(Point(20, 48)))
        Assert.assertEquals(Point(20, 1), v.region(Point(22, 0)))
        Assert.assertEquals(Point(20, 1), v.region(Point(22, 2)))
        Assert.assertEquals(Point(20, 1), v.region(Point(22, 4)))
        Assert.assertEquals(Point(24, 10), v.region(Point(22, 6)))
        Assert.assertEquals(Point(24, 10), v.region(Point(22, 8)))
        Assert.assertEquals(Point(24, 10), v.region(Point(22, 10)))
        Assert.assertEquals(Point(23, 12), v.region(Point(22, 12)))
        Assert.assertEquals(Point(23, 12), v.region(Point(22, 14)))
        Assert.assertEquals(Point(23, 12), v.region(Point(22, 16)))
        Assert.assertEquals(Point(27, 20), v.region(Point(22, 18)))
        Assert.assertEquals(Point(27, 20), v.region(Point(22, 20)))
        Assert.assertEquals(Point(23, 25), v.region(Point(22, 22)))
        Assert.assertEquals(Point(23, 25), v.region(Point(22, 24)))
        Assert.assertEquals(Point(23, 25), v.region(Point(22, 26)))
        Assert.assertEquals(Point(23, 25), v.region(Point(22, 28)))
        Assert.assertEquals(Point(23, 25), v.region(Point(22, 30)))
        Assert.assertEquals(Point(23, 25), v.region(Point(22, 32)))
        Assert.assertEquals(Point(29, 35), v.region(Point(22, 34)))
        Assert.assertEquals(Point(16, 38), v.region(Point(22, 36)))
        Assert.assertEquals(Point(17, 40), v.region(Point(22, 38)))
        Assert.assertEquals(Point(17, 40), v.region(Point(22, 40)))
        Assert.assertEquals(Point(20, 45), v.region(Point(22, 42)))
        Assert.assertEquals(Point(20, 45), v.region(Point(22, 44)))
        Assert.assertEquals(Point(20, 45), v.region(Point(22, 46)))
        Assert.assertEquals(Point(20, 45), v.region(Point(22, 48)))
        Assert.assertEquals(Point(26, 1), v.region(Point(24, 0)))
        Assert.assertEquals(Point(26, 1), v.region(Point(24, 2)))
        Assert.assertEquals(Point(26, 1), v.region(Point(24, 4)))
        Assert.assertEquals(Point(24, 10), v.region(Point(24, 6)))
        Assert.assertEquals(Point(24, 10), v.region(Point(24, 8)))
        Assert.assertEquals(Point(24, 10), v.region(Point(24, 10)))
        Assert.assertEquals(Point(23, 12), v.region(Point(24, 12)))
        Assert.assertEquals(Point(23, 12), v.region(Point(24, 14)))
        Assert.assertEquals(Point(23, 12), v.region(Point(24, 16)))
        Assert.assertEquals(Point(27, 20), v.region(Point(24, 18)))
        Assert.assertEquals(Point(27, 20), v.region(Point(24, 20)))
        Assert.assertEquals(Point(23, 25), v.region(Point(24, 22)))
        Assert.assertEquals(Point(23, 25), v.region(Point(24, 24)))
        Assert.assertEquals(Point(23, 25), v.region(Point(24, 26)))
        Assert.assertEquals(Point(23, 25), v.region(Point(24, 28)))
        Assert.assertEquals(Point(23, 25), v.region(Point(24, 30)))
        Assert.assertEquals(Point(29, 35), v.region(Point(24, 32)))
        Assert.assertEquals(Point(29, 35), v.region(Point(24, 34)))
        Assert.assertEquals(Point(29, 35), v.region(Point(24, 36)))
        Assert.assertEquals(Point(29, 39), v.region(Point(24, 38)))
        Assert.assertEquals(Point(29, 39), v.region(Point(24, 40)))
        Assert.assertEquals(Point(20, 45), v.region(Point(24, 42)))
        Assert.assertEquals(Point(20, 45), v.region(Point(24, 44)))
        Assert.assertEquals(Point(20, 45), v.region(Point(24, 46)))
        Assert.assertEquals(Point(20, 45), v.region(Point(24, 48)))
        Assert.assertEquals(Point(26, 1), v.region(Point(26, 0)))
        Assert.assertEquals(Point(26, 1), v.region(Point(26, 2)))
        Assert.assertEquals(Point(26, 1), v.region(Point(26, 4)))
        Assert.assertEquals(Point(24, 10), v.region(Point(26, 6)))
        Assert.assertEquals(Point(24, 10), v.region(Point(26, 8)))
        Assert.assertEquals(Point(24, 10), v.region(Point(26, 10)))
        Assert.assertEquals(Point(24, 10), v.region(Point(26, 12)))
        Assert.assertEquals(Point(23, 12), v.region(Point(26, 14)))
        Assert.assertEquals(Point(27, 20), v.region(Point(26, 16)))
        Assert.assertEquals(Point(27, 20), v.region(Point(26, 18)))
        Assert.assertEquals(Point(27, 20), v.region(Point(26, 20)))
        Assert.assertEquals(Point(27, 20), v.region(Point(26, 22)))
        Assert.assertEquals(Point(23, 25), v.region(Point(26, 24)))
        Assert.assertEquals(Point(23, 25), v.region(Point(26, 26)))
        Assert.assertEquals(Point(23, 25), v.region(Point(26, 28)))
        Assert.assertEquals(Point(29, 35), v.region(Point(26, 30)))
        Assert.assertEquals(Point(29, 35), v.region(Point(26, 32)))
        Assert.assertEquals(Point(29, 35), v.region(Point(26, 34)))
        Assert.assertEquals(Point(29, 35), v.region(Point(26, 36)))
        Assert.assertEquals(Point(29, 39), v.region(Point(26, 38)))
        Assert.assertEquals(Point(29, 39), v.region(Point(26, 40)))
        Assert.assertEquals(Point(29, 39), v.region(Point(26, 42)))
        Assert.assertEquals(Point(29, 39), v.region(Point(26, 44)))
        Assert.assertEquals(Point(20, 45), v.region(Point(26, 46)))
        Assert.assertEquals(Point(20, 45), v.region(Point(26, 48)))
        Assert.assertEquals(Point(26, 1), v.region(Point(28, 0)))
        Assert.assertEquals(Point(26, 1), v.region(Point(28, 2)))
        Assert.assertEquals(Point(26, 1), v.region(Point(28, 4)))
        Assert.assertEquals(Point(32, 9), v.region(Point(28, 6)))
        Assert.assertEquals(Point(32, 9), v.region(Point(28, 8)))
        Assert.assertEquals(Point(24, 10), v.region(Point(28, 10)))
        Assert.assertEquals(Point(24, 10), v.region(Point(28, 12)))
        Assert.assertEquals(Point(23, 12), v.region(Point(28, 14)))
        Assert.assertEquals(Point(29, 20), v.region(Point(28, 16)))
        Assert.assertEquals(Point(29, 20), v.region(Point(28, 18)))
        Assert.assertEquals(Point(29, 20), v.region(Point(28, 20)))
        Assert.assertEquals(Point(29, 20), v.region(Point(28, 22)))
        Assert.assertEquals(Point(29, 20), v.region(Point(28, 24)))
        Assert.assertEquals(Point(23, 25), v.region(Point(28, 26)))
        Assert.assertEquals(Point(23, 25), v.region(Point(28, 28)))
        Assert.assertEquals(Point(29, 35), v.region(Point(28, 30)))
        Assert.assertEquals(Point(29, 35), v.region(Point(28, 32)))
        Assert.assertEquals(Point(29, 35), v.region(Point(28, 34)))
        Assert.assertEquals(Point(29, 35), v.region(Point(28, 36)))
        Assert.assertEquals(Point(29, 39), v.region(Point(28, 38)))
        Assert.assertEquals(Point(29, 39), v.region(Point(28, 40)))
        Assert.assertEquals(Point(29, 39), v.region(Point(28, 42)))
        Assert.assertEquals(Point(32, 41), v.region(Point(28, 44)))
        Assert.assertEquals(Point(32, 41), v.region(Point(28, 46)))
        Assert.assertEquals(Point(32, 41), v.region(Point(28, 48)))
        Assert.assertEquals(Point(26, 1), v.region(Point(30, 0)))
        Assert.assertEquals(Point(26, 1), v.region(Point(30, 2)))
        Assert.assertEquals(Point(26, 1), v.region(Point(30, 4)))
        Assert.assertEquals(Point(32, 9), v.region(Point(30, 6)))
        Assert.assertEquals(Point(32, 9), v.region(Point(30, 8)))
        Assert.assertEquals(Point(32, 9), v.region(Point(30, 10)))
        Assert.assertEquals(Point(32, 9), v.region(Point(30, 12)))
        Assert.assertEquals(Point(32, 9), v.region(Point(30, 14)))
        Assert.assertEquals(Point(29, 20), v.region(Point(30, 16)))
        Assert.assertEquals(Point(29, 20), v.region(Point(30, 18)))
        Assert.assertEquals(Point(29, 20), v.region(Point(30, 20)))
        Assert.assertEquals(Point(29, 20), v.region(Point(30, 22)))
        Assert.assertEquals(Point(29, 20), v.region(Point(30, 24)))
        Assert.assertEquals(Point(29, 20), v.region(Point(30, 26)))
        Assert.assertEquals(Point(29, 35), v.region(Point(30, 28)))
        Assert.assertEquals(Point(29, 35), v.region(Point(30, 30)))
        Assert.assertEquals(Point(29, 35), v.region(Point(30, 32)))
        Assert.assertEquals(Point(29, 35), v.region(Point(30, 34)))
        Assert.assertEquals(Point(29, 35), v.region(Point(30, 36)))
        Assert.assertEquals(Point(29, 39), v.region(Point(30, 38)))
        Assert.assertEquals(Point(29, 39), v.region(Point(30, 40)))
        Assert.assertEquals(Point(32, 41), v.region(Point(30, 42)))
        Assert.assertEquals(Point(32, 41), v.region(Point(30, 44)))
        Assert.assertEquals(Point(32, 41), v.region(Point(30, 46)))
        Assert.assertEquals(Point(32, 41), v.region(Point(30, 48)))
        Assert.assertEquals(Point(26, 1), v.region(Point(32, 0)))
        Assert.assertEquals(Point(26, 1), v.region(Point(32, 2)))
        Assert.assertEquals(Point(32, 9), v.region(Point(32, 4)))
        Assert.assertEquals(Point(32, 9), v.region(Point(32, 6)))
        Assert.assertEquals(Point(32, 9), v.region(Point(32, 8)))
        Assert.assertEquals(Point(32, 9), v.region(Point(32, 10)))
        Assert.assertEquals(Point(32, 9), v.region(Point(32, 12)))
        Assert.assertEquals(Point(32, 9), v.region(Point(32, 14)))
        Assert.assertEquals(Point(29, 20), v.region(Point(32, 16)))
        Assert.assertEquals(Point(29, 20), v.region(Point(32, 18)))
        Assert.assertEquals(Point(34, 21), v.region(Point(32, 20)))
        Assert.assertEquals(Point(34, 21), v.region(Point(32, 22)))
        Assert.assertEquals(Point(34, 21), v.region(Point(32, 24)))
        Assert.assertEquals(Point(34, 21), v.region(Point(32, 26)))
        Assert.assertEquals(Point(34, 21), v.region(Point(32, 28)))
        Assert.assertEquals(Point(29, 35), v.region(Point(32, 30)))
        Assert.assertEquals(Point(29, 35), v.region(Point(32, 32)))
        Assert.assertEquals(Point(29, 35), v.region(Point(32, 34)))
        Assert.assertEquals(Point(29, 35), v.region(Point(32, 36)))
        Assert.assertEquals(Point(32, 41), v.region(Point(32, 38)))
        Assert.assertEquals(Point(32, 41), v.region(Point(32, 40)))
        Assert.assertEquals(Point(32, 41), v.region(Point(32, 42)))
        Assert.assertEquals(Point(32, 41), v.region(Point(32, 44)))
        Assert.assertEquals(Point(32, 41), v.region(Point(32, 46)))
        Assert.assertEquals(Point(32, 41), v.region(Point(32, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(34, 0)))
        Assert.assertEquals(Point(32, 9), v.region(Point(34, 2)))
        Assert.assertEquals(Point(32, 9), v.region(Point(34, 4)))
        Assert.assertEquals(Point(32, 9), v.region(Point(34, 6)))
        Assert.assertEquals(Point(32, 9), v.region(Point(34, 8)))
        Assert.assertEquals(Point(32, 9), v.region(Point(34, 10)))
        Assert.assertEquals(Point(36, 11), v.region(Point(34, 12)))
        Assert.assertEquals(Point(36, 11), v.region(Point(34, 14)))
        Assert.assertEquals(Point(34, 21), v.region(Point(34, 16)))
        Assert.assertEquals(Point(34, 21), v.region(Point(34, 18)))
        Assert.assertEquals(Point(34, 21), v.region(Point(34, 20)))
        Assert.assertEquals(Point(34, 21), v.region(Point(34, 22)))
        Assert.assertEquals(Point(34, 21), v.region(Point(34, 24)))
        Assert.assertEquals(Point(34, 21), v.region(Point(34, 26)))
        Assert.assertEquals(Point(40, 28), v.region(Point(34, 28)))
        Assert.assertEquals(Point(37, 34), v.region(Point(34, 30)))
        Assert.assertEquals(Point(37, 34), v.region(Point(34, 32)))
        Assert.assertEquals(Point(37, 34), v.region(Point(34, 34)))
        Assert.assertEquals(Point(37, 34), v.region(Point(34, 36)))
        Assert.assertEquals(Point(37, 39), v.region(Point(34, 38)))
        Assert.assertEquals(Point(32, 41), v.region(Point(34, 40)))
        Assert.assertEquals(Point(32, 41), v.region(Point(34, 42)))
        Assert.assertEquals(Point(32, 41), v.region(Point(34, 44)))
        Assert.assertEquals(Point(32, 41), v.region(Point(34, 46)))
        Assert.assertEquals(Point(32, 41), v.region(Point(34, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(36, 0)))
        Assert.assertEquals(Point(41, 4), v.region(Point(36, 2)))
        Assert.assertEquals(Point(41, 4), v.region(Point(36, 4)))
        Assert.assertEquals(Point(32, 9), v.region(Point(36, 6)))
        Assert.assertEquals(Point(36, 11), v.region(Point(36, 8)))
        Assert.assertEquals(Point(36, 11), v.region(Point(36, 10)))
        Assert.assertEquals(Point(36, 11), v.region(Point(36, 12)))
        Assert.assertEquals(Point(36, 11), v.region(Point(36, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(36, 16)))
        Assert.assertEquals(Point(34, 21), v.region(Point(36, 18)))
        Assert.assertEquals(Point(34, 21), v.region(Point(36, 20)))
        Assert.assertEquals(Point(34, 21), v.region(Point(36, 22)))
        Assert.assertEquals(Point(34, 21), v.region(Point(36, 24)))
        Assert.assertEquals(Point(40, 26), v.region(Point(36, 26)))
        Assert.assertEquals(Point(40, 28), v.region(Point(36, 28)))
        Assert.assertEquals(Point(37, 34), v.region(Point(36, 30)))
        Assert.assertEquals(Point(37, 34), v.region(Point(36, 32)))
        Assert.assertEquals(Point(37, 34), v.region(Point(36, 34)))
        Assert.assertEquals(Point(37, 34), v.region(Point(36, 36)))
        Assert.assertEquals(Point(37, 39), v.region(Point(36, 38)))
        Assert.assertEquals(Point(37, 39), v.region(Point(36, 40)))
        Assert.assertEquals(Point(37, 39), v.region(Point(36, 42)))
        Assert.assertEquals(Point(32, 41), v.region(Point(36, 44)))
        Assert.assertEquals(Point(32, 41), v.region(Point(36, 46)))
        Assert.assertEquals(Point(32, 41), v.region(Point(36, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(38, 0)))
        Assert.assertEquals(Point(41, 4), v.region(Point(38, 2)))
        Assert.assertEquals(Point(41, 4), v.region(Point(38, 4)))
        Assert.assertEquals(Point(41, 4), v.region(Point(38, 6)))
        Assert.assertEquals(Point(36, 11), v.region(Point(38, 8)))
        Assert.assertEquals(Point(36, 11), v.region(Point(38, 10)))
        Assert.assertEquals(Point(36, 11), v.region(Point(38, 12)))
        Assert.assertEquals(Point(39, 15), v.region(Point(38, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(38, 16)))
        Assert.assertEquals(Point(39, 15), v.region(Point(38, 18)))
        Assert.assertEquals(Point(34, 21), v.region(Point(38, 20)))
        Assert.assertEquals(Point(34, 21), v.region(Point(38, 22)))
        Assert.assertEquals(Point(40, 26), v.region(Point(38, 24)))
        Assert.assertEquals(Point(40, 26), v.region(Point(38, 26)))
        Assert.assertEquals(Point(40, 28), v.region(Point(38, 28)))
        Assert.assertEquals(Point(40, 28), v.region(Point(38, 30)))
        Assert.assertEquals(Point(37, 34), v.region(Point(38, 32)))
        Assert.assertEquals(Point(37, 34), v.region(Point(38, 34)))
        Assert.assertEquals(Point(37, 34), v.region(Point(38, 36)))
        Assert.assertEquals(Point(37, 39), v.region(Point(38, 38)))
        Assert.assertEquals(Point(37, 39), v.region(Point(38, 40)))
        Assert.assertEquals(Point(37, 39), v.region(Point(38, 42)))
        Assert.assertEquals(Point(37, 39), v.region(Point(38, 44)))
        Assert.assertEquals(Point(37, 39), v.region(Point(38, 46)))
        Assert.assertEquals(Point(44, 42), v.region(Point(38, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(40, 0)))
        Assert.assertEquals(Point(41, 4), v.region(Point(40, 2)))
        Assert.assertEquals(Point(41, 4), v.region(Point(40, 4)))
        Assert.assertEquals(Point(41, 4), v.region(Point(40, 6)))
        Assert.assertEquals(Point(42, 9), v.region(Point(40, 8)))
        Assert.assertEquals(Point(42, 9), v.region(Point(40, 10)))
        Assert.assertEquals(Point(39, 15), v.region(Point(40, 12)))
        Assert.assertEquals(Point(39, 15), v.region(Point(40, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(40, 16)))
        Assert.assertEquals(Point(39, 15), v.region(Point(40, 18)))
        Assert.assertEquals(Point(39, 15), v.region(Point(40, 20)))
        Assert.assertEquals(Point(40, 26), v.region(Point(40, 22)))
        Assert.assertEquals(Point(40, 26), v.region(Point(40, 24)))
        Assert.assertEquals(Point(40, 26), v.region(Point(40, 26)))
        Assert.assertEquals(Point(40, 28), v.region(Point(40, 28)))
        Assert.assertEquals(Point(40, 28), v.region(Point(40, 30)))
        Assert.assertEquals(Point(41, 34), v.region(Point(40, 32)))
        Assert.assertEquals(Point(41, 34), v.region(Point(40, 34)))
        Assert.assertEquals(Point(42, 36), v.region(Point(40, 36)))
        Assert.assertEquals(Point(42, 36), v.region(Point(40, 38)))
        Assert.assertEquals(Point(37, 39), v.region(Point(40, 40)))
        Assert.assertEquals(Point(44, 42), v.region(Point(40, 42)))
        Assert.assertEquals(Point(44, 42), v.region(Point(40, 44)))
        Assert.assertEquals(Point(44, 42), v.region(Point(40, 46)))
        Assert.assertEquals(Point(44, 42), v.region(Point(40, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(42, 0)))
        Assert.assertEquals(Point(41, 4), v.region(Point(42, 2)))
        Assert.assertEquals(Point(41, 4), v.region(Point(42, 4)))
        Assert.assertEquals(Point(41, 4), v.region(Point(42, 6)))
        Assert.assertEquals(Point(42, 9), v.region(Point(42, 8)))
        Assert.assertEquals(Point(42, 9), v.region(Point(42, 10)))
        Assert.assertEquals(Point(42, 9), v.region(Point(42, 12)))
        Assert.assertEquals(Point(39, 15), v.region(Point(42, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(42, 16)))
        Assert.assertEquals(Point(39, 15), v.region(Point(42, 18)))
        Assert.assertEquals(Point(45, 25), v.region(Point(42, 20)))
        Assert.assertEquals(Point(45, 25), v.region(Point(42, 22)))
        Assert.assertEquals(Point(40, 26), v.region(Point(42, 24)))
        Assert.assertEquals(Point(40, 26), v.region(Point(42, 26)))
        Assert.assertEquals(Point(40, 28), v.region(Point(42, 28)))
        Assert.assertEquals(Point(43, 30), v.region(Point(42, 30)))
        Assert.assertEquals(Point(41, 34), v.region(Point(42, 32)))
        Assert.assertEquals(Point(41, 34), v.region(Point(42, 34)))
        Assert.assertEquals(Point(42, 36), v.region(Point(42, 36)))
        Assert.assertEquals(Point(42, 36), v.region(Point(42, 38)))
        Assert.assertEquals(Point(44, 42), v.region(Point(42, 40)))
        Assert.assertEquals(Point(44, 42), v.region(Point(42, 42)))
        Assert.assertEquals(Point(44, 42), v.region(Point(42, 44)))
        Assert.assertEquals(Point(44, 42), v.region(Point(42, 46)))
        Assert.assertEquals(Point(44, 42), v.region(Point(42, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(44, 0)))
        Assert.assertEquals(Point(41, 4), v.region(Point(44, 2)))
        Assert.assertEquals(Point(41, 4), v.region(Point(44, 4)))
        Assert.assertEquals(Point(47, 7), v.region(Point(44, 6)))
        Assert.assertEquals(Point(42, 9), v.region(Point(44, 8)))
        Assert.assertEquals(Point(42, 9), v.region(Point(44, 10)))
        Assert.assertEquals(Point(42, 9), v.region(Point(44, 12)))
        Assert.assertEquals(Point(39, 15), v.region(Point(44, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(44, 16)))
        Assert.assertEquals(Point(39, 15), v.region(Point(44, 18)))
        Assert.assertEquals(Point(45, 25), v.region(Point(44, 20)))
        Assert.assertEquals(Point(45, 25), v.region(Point(44, 22)))
        Assert.assertEquals(Point(45, 25), v.region(Point(44, 24)))
        Assert.assertEquals(Point(44, 27), v.region(Point(44, 26)))
        Assert.assertEquals(Point(44, 27), v.region(Point(44, 28)))
        Assert.assertEquals(Point(43, 30), v.region(Point(44, 30)))
        Assert.assertEquals(Point(43, 30), v.region(Point(44, 32)))
        Assert.assertEquals(Point(42, 36), v.region(Point(44, 34)))
        Assert.assertEquals(Point(42, 36), v.region(Point(44, 36)))
        Assert.assertEquals(Point(42, 36), v.region(Point(44, 38)))
        Assert.assertEquals(Point(44, 42), v.region(Point(44, 40)))
        Assert.assertEquals(Point(44, 42), v.region(Point(44, 42)))
        Assert.assertEquals(Point(44, 42), v.region(Point(44, 44)))
        Assert.assertEquals(Point(44, 42), v.region(Point(44, 46)))
        Assert.assertEquals(Point(44, 42), v.region(Point(44, 48)))
        Assert.assertEquals(Point(41, 4), v.region(Point(46, 0)))
        Assert.assertEquals(Point(47, 7), v.region(Point(46, 2)))
        Assert.assertEquals(Point(47, 7), v.region(Point(46, 4)))
        Assert.assertEquals(Point(47, 7), v.region(Point(46, 6)))
        Assert.assertEquals(Point(47, 7), v.region(Point(46, 8)))
        Assert.assertEquals(Point(47, 7), v.region(Point(46, 10)))
        Assert.assertEquals(Point(42, 9), v.region(Point(46, 12)))
        Assert.assertEquals(Point(42, 9), v.region(Point(46, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(46, 16)))
        Assert.assertEquals(Point(45, 25), v.region(Point(46, 18)))
        Assert.assertEquals(Point(45, 25), v.region(Point(46, 20)))
        Assert.assertEquals(Point(45, 25), v.region(Point(46, 22)))
        Assert.assertEquals(Point(45, 25), v.region(Point(46, 24)))
        Assert.assertEquals(Point(45, 25), v.region(Point(46, 26)))
        Assert.assertEquals(Point(47, 27), v.region(Point(46, 28)))
        Assert.assertEquals(Point(43, 30), v.region(Point(46, 30)))
        Assert.assertEquals(Point(43, 30), v.region(Point(46, 32)))
        Assert.assertEquals(Point(42, 36), v.region(Point(46, 34)))
        Assert.assertEquals(Point(42, 36), v.region(Point(46, 36)))
        Assert.assertEquals(Point(44, 42), v.region(Point(46, 38)))
        Assert.assertEquals(Point(44, 42), v.region(Point(46, 40)))
        Assert.assertEquals(Point(44, 42), v.region(Point(46, 42)))
        Assert.assertEquals(Point(44, 42), v.region(Point(46, 44)))
        Assert.assertEquals(Point(44, 42), v.region(Point(46, 46)))
        Assert.assertEquals(Point(44, 42), v.region(Point(46, 48)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 0)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 2)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 4)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 6)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 8)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 10)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 12)))
        Assert.assertEquals(Point(47, 7), v.region(Point(48, 14)))
        Assert.assertEquals(Point(39, 15), v.region(Point(48, 16)))
        Assert.assertEquals(Point(45, 25), v.region(Point(48, 18)))
        Assert.assertEquals(Point(45, 25), v.region(Point(48, 20)))
        Assert.assertEquals(Point(45, 25), v.region(Point(48, 22)))
        Assert.assertEquals(Point(45, 25), v.region(Point(48, 24)))
        Assert.assertEquals(Point(47, 27), v.region(Point(48, 26)))
        Assert.assertEquals(Point(47, 27), v.region(Point(48, 28)))
        Assert.assertEquals(Point(47, 27), v.region(Point(48, 30)))
        Assert.assertEquals(Point(47, 27), v.region(Point(48, 32)))
        Assert.assertEquals(Point(42, 36), v.region(Point(48, 34)))
        Assert.assertEquals(Point(42, 36), v.region(Point(48, 36)))
        Assert.assertEquals(Point(44, 42), v.region(Point(48, 38)))
        Assert.assertEquals(Point(44, 42), v.region(Point(48, 40)))
        Assert.assertEquals(Point(44, 42), v.region(Point(48, 42)))
        Assert.assertEquals(Point(44, 42), v.region(Point(48, 44)))
        Assert.assertEquals(Point(44, 42), v.region(Point(48, 46)))
        Assert.assertEquals(Point(44, 42), v.region(Point(48, 48)))
    }

    @Test
    fun testManhattanDistance() {
        val v = Voronoi(
                listOf(
                        Point(1, 6),
                        Point(4, 3),
                        Point(5, 3),
                        Point(6, 8),
                        Point(9, 6),
                        Point(3, 3),
                        Point(5, 1),
                        Point(1, 0),
                        Point(4, 3),
                        Point(3, 6)
                ), Point.MANHATTAN_DISTANCE_FUNC
        )
        Assert.assertEquals(Point(1, 0), v.region(Point(0, 0)))
        Assert.assertEquals(Point(1, 6), v.region(Point(0, 4)))
        Assert.assertEquals(Point(1, 6), v.region(Point(0, 8)))
        Assert.assertEquals(Point(5, 1), v.region(Point(4, 0)))
        Assert.assertEquals(Point(4, 3), v.region(Point(4, 4)))
        Assert.assertEquals(Point(6, 8), v.region(Point(4, 8)))
        Assert.assertEquals(Point(5, 1), v.region(Point(8, 0)))
        Assert.assertEquals(Point(9, 6), v.region(Point(8, 4)))
        Assert.assertEquals(Point(6, 8), v.region(Point(8, 8)))
    }
}